<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        width: 400px;
        height: 400px;
        font-size: 40px;
        border: solid;
        margin-left: 100px;
        overflow: auto;
        padding: 20px;
      }
      #box p {
        height: 200px;
        border: solid;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <p>hello p1</p>
      <p>hello p2</p>
      <p>hello p3</p>
      <p>hello p4</p>
      <p>hello p5</p>
    </div>
    <script>
      const box = document.getElementById("box");
      box.onscroll = function () {
        const r = box.scrollHeight - box.offsetHeight - box.scrollTop < 60;
        if (r) {
          // 新内容
          const p = document.createElement("p");
          p.innerHTML = "new P";
          box.append(p);
        }
      };
    </script>
  </body>
</html>
